<?php

namespace app\admin\controller\product;

// use think\admin\Controller;
use app\common\controller\Backend;


// class Product extends Controller
class Product extends Backend
{

  // 当前对象模型
  protected $model = null;

  public function _initialize()
  {
    parent::_initialize();
    $this->model = model('Product.Type');
  }


  /*  public function index()
  {
    $productTypes = $this->model::select();
    $this->assign('productTypes', $productTypes);
    return $this->fetch();
  } */
  public function index()
  {
    if ($this->request->isAjax()) {

      list($where, $sort, $order, $offset, $limit) = $this->buildparams();

      $total = $this->model
        ->where($where)
        ->order($sort, $order)
        ->count();

      $list = $this->model
        ->where($where)
        ->order($sort, $order)
        ->limit($offset, $limit)
        ->select();

      $result = array("total" => $total, "rows" => $list);
      // $this->assign('productTypes', $result);

      return json($result);
    }
    return $this->view->fetch();
  }

}
